<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>主机文件配置指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8f9fa;
            color: #2d3748;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #2d3748;
            color: #e2e8f0;
            border-radius: 0.5rem;
            position: relative;
        }
        .code-block:before {
            content: '';
            position: absolute;
            top: 12px;
            left: 12px;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: #fc5c65;
            box-shadow: 20px 0 #f7b731, 40px 0 #26de81;
        }
        .step-card {
            transition: all 0.3s ease;
            border-left: 4px solid transparent;
        }
        .step-card:hover {
            transform: translateY(-5px);
            border-left-color: #667eea;
        }
        .mermaid-container {
            background: white;
            border-radius: 0.5rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:py-32">
        <div class="container mx-auto max-w-4xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">优化GitHub访问体验</h1>
                    <p class="text-xl opacity-90 mb-6">通过修改hosts文件解决GitHub访问问题</p>
                    <div class="flex space-x-4">
                        <a href="#tutorial" class="bg-white text-indigo-700 px-6 py-3 rounded-lg font-medium hover:bg-opacity-90 transition duration-300">开始配置</a>
                        <a href="#why" class="border border-white px-6 py-3 rounded-lg font-medium hover:bg-white hover:bg-opacity-10 transition duration-300">了解原理</a>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="relative">
                        <div class="absolute -top-4 -left-4 w-16 h-16 bg-yellow-400 rounded-lg opacity-20 animate-pulse"></div>
                        <div class="absolute -bottom-4 -right-4 w-16 h-16 bg-purple-400 rounded-lg opacity-20 animate-pulse"></div>
                        <div class="relative bg-white bg-opacity-10 backdrop-blur-sm p-6 rounded-xl border border-white border-opacity-20">
                            <div class="flex items-center mb-4">
                                <div class="w-3 h-3 bg-red-500 rounded-full mr-2"></div>
                                <div class="w-3 h-3 bg-yellow-500 rounded-full mr-2"></div>
                                <div class="w-3 h-3 bg-green-500 rounded-full"></div>
                            </div>
                            <div class="code-block p-6 text-sm">
                                <code>199.232.69.194 github.global.ssl.fastly.net<br>
                                185.199.108.153 assets-cdn.github.com<br>
                                185.199.109.153 assets-cdn.github.com<br>
                                185.199.110.153 assets-cdn.github.com<br>
                                185.199.111.153 assets-cdn.github.com</code>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-4xl px-4 py-16">
        <!-- Introduction -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-6 font-serif">为什么需要修改hosts文件？</h2>
            <p class="text-lg leading-relaxed mb-6">在中国大陆地区，由于网络环境特殊，访问GitHub等国外服务时可能会遇到速度缓慢或无法访问的情况。通过修改hosts文件，将GitHub相关域名指向更快的IP地址，可以显著改善访问体验。</p>
            
            <div class="grid md:grid-cols-2 gap-8 mb-10">
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-bolt text-yellow-500 text-2xl mr-3"></i>
                        <h3 class="text-xl font-semibold">加速访问</h3>
                    </div>
                    <p class="text-gray-600">绕过DNS污染，直接连接最优服务器节点，提升加载速度。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-shield-alt text-blue-500 text-2xl mr-3"></i>
                        <h3 class="text-xl font-semibold">提高稳定性</h3>
                    </div>
                    <p class="text-gray-600">减少因DNS解析问题导致的连接中断，确保稳定访问。</p>
                </div>
            </div>
        </section>

        <!-- Tutorial Section -->
        <section id="tutorial" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 font-serif">配置步骤</h2>
            
            <div class="space-y-8">
                <!-- Step 1 -->
                <div class="step-card bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-start">
                        <div class="bg-indigo-100 text-indigo-700 w-10 h-10 rounded-full flex items-center justify-center mr-4 flex-shrink-0">
                            <span class="font-bold">1</span>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-3">找到hosts文件</h3>
                            <p class="text-gray-600 mb-4">hosts文件位于以下路径：</p>
                            <div class="code-block p-4 mb-4">
                                <code>Windows: C:\Windows\System32\drivers\etc\hosts<br>
                                macOS/Linux: /etc/hosts</code>
                            </div>
                            <p class="text-gray-600">注意：修改hosts文件需要管理员/root权限。</p>
                        </div>
                    </div>
                </div>

                <!-- Step 2 -->
                <div class="step-card bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-start">
                        <div class="bg-indigo-100 text-indigo-700 w-10 h-10 rounded-full flex items-center justify-center mr-4 flex-shrink-0">
                            <span class="font-bold">2</span>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-3">编辑hosts文件</h3>
                            <p class="text-gray-600 mb-4">在文件末尾添加以下内容：</p>
                            <div class="code-block p-4 mb-4">
                                <code>199.232.69.194 github.global.ssl.fastly.net<br>
                                185.199.108.153 assets-cdn.github.com<br>
                                185.199.109.153 assets-cdn.github.com<br>
                                185.199.110.153 assets-cdn.github.com<br>
                                185.199.111.153 assets-cdn.github.com</code>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Step 3 -->
                <div class="step-card bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-start">
                        <div class="bg-indigo-100 text-indigo-700 w-10 h-10 rounded-full flex items-center justify-center mr-4 flex-shrink-0">
                            <span class="font-bold">3</span>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-3">刷新DNS缓存</h3>
                            <p class="text-gray-600 mb-4">保存hosts文件后，需要刷新DNS缓存使更改生效：</p>
                            <div class="code-block p-4 mb-4">
                                <code>Windows: ipconfig /flushdns<br>
                                macOS: sudo dscacheutil -flushcache<br>
                                Linux: sudo systemd-resolve --flush-caches</code>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Technical Explanation -->
        <section id="why" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 font-serif">技术原理</h2>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="md:flex">
                    <div class="md:w-1/2 p-8">
                        <h3 class="text-xl font-semibold mb-4">什么是hosts文件？</h3>
                        <p class="text-gray-600 mb-6">hosts文件是计算机上一个简单的文本文件，用于将主机名映射到IP地址。它会在DNS查询之前被检查，因此可以用来覆盖DNS解析结果。</p>
                        
                        <h3 class="text-xl font-semibold mb-4">为什么这些IP能加速访问？</h3>
                        <p class="text-gray-600">我们选择的是GitHub的CDN节点IP，这些IP通常有更好的网络连接和更快的响应速度。通过直接指向这些IP，避免了因DNS污染或解析不当导致的访问问题。</p>
                    </div>
                    <div class="md:w-1/2 bg-gray-50 p-8">
                        <h3 class="text-xl font-semibold mb-4">DNS解析流程对比</h3>
                        <div class="mermaid-container">
                            <div class="mermaid">
                                graph LR
                                A[用户访问github.com] -->|正常DNS| B[DNS服务器]
                                B -->|可能被污染| C[返回错误IP]
                                A -->|修改hosts后| D[直接访问正确IP]
                                D --> E[快速响应]
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Tips Section -->
        <section class="mb-10">
            <h2 class="text-3xl font-bold mb-8 font-serif">注意事项</h2>
            <div class="bg-yellow-50 border-l-4 border-yellow-400 p-6 rounded-r-lg">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <i class="fas fa-exclamation-triangle text-yellow-500 text-2xl"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-lg font-medium text-yellow-800">重要提示</h3>
                        <div class="mt-2 text-yellow-700">
                            <ul class="list-disc pl-5 space-y-1">
                                <li>IP地址可能会变更，如果发现访问变慢，需要更新hosts文件</li>
                                <li>修改hosts文件前建议备份原有文件</li>
                                <li>某些安全软件可能会阻止修改hosts文件，需要暂时关闭</li>
                                <li>如果使用VPN，可能不需要修改hosts文件</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>